#include <iostream>
#include <vector>
using namespace std;

class Company
{
protected:
    double taxRate; // 税率
    int profit;     // 营收
public:
    Company() : taxRate(0), profit(0)
    {
    }
    void addProfit(int profit)
    {
        this->profit += profit;
    }
    double getTaxRate()
    {
        return profit * taxRate;
    }
};
class Service : public Company
{
public:
    Service()
    {
        taxRate = 0.05;
    }
};
class Manufacturer : public Company
{
public:
    Manufacturer()
    {
        taxRate = 0.17;
    }
};

int main()
{
    vector<Company> companys;

    char t;     // 类型
    int profit; // 营收

    Company *company;
    while (cin >> t >> profit)
    {
        switch (t)
        {
        case 'S':
            company = new Service();
            company->addProfit(profit);
            companys.push_back(*company);
            break;
        case 'M':
            company = new Manufacturer();
            company->addProfit(profit);
            companys.push_back(*company);
            break;
        }
    }

    // 输出总额
    double totalTax = 0;
    for (vector<Company>::iterator iter = companys.begin(); iter != companys.end(); iter++)
    {
        totalTax += iter->getTaxRate();
    }
    cout << totalTax << endl;
}